<#assign module="member"/>

<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/form.css">
</@override>
<@override name="body">

	<div class="row">
		<div class="col-md-12 col-lg-12">
		<div class="tabbable"> <!-- Only required for left/right tabs -->
			<ul class="nav nav-tabs">
			    <li class="active"><a href="javascript:;">个人用户</a></li>
				<li><a href="${ctx}/member/addCompany">企业用户</a></li>
				<li><a href="${ctx}/member/addVip">VIP用户</a></li>
			</ul>
			  
			<div class="tab-content">
			
			    <div class="tab-pane active" id="tab1">
		    		<div class="row margin-top">
						<div class="col-xs-12">
							<div class="table-responsive">
								<div class="panel panel-default">
									<div class="panel-heading">
										填写客户信息
									</div>
									<div class="panel-body">
				    				<form class="form-horizontal" id="submit_form" action="${ctx}/member/create" method="post">
						                <input type="hidden" id="CSRFToken" name="CSRFToken" value="${CSRFToken}"/>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label">客户类型：</label>
						                   	<div class="col-sm-3">
						                   		<p class="form-control-static">个人用户</p>
						               		</div>
						                </div>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label"><em>*</em>手机号：</label>
						                   	<div class="col-sm-3">
						                   		<input class="form-control" id="phone" name="memberAccounts[0].phone" type="text" <#if member.memberAccounts?? && (member.memberAccounts?size>0)>value="${member.memberAccounts[0].phone?if_exists}"</#if> required>
						               		</div>
						                </div>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label"><em>*</em>代驾收费：</label>
						                    <div class="col-sm-3">
							                    <select class="form-control" id="areaId" name="areaId">
							                    	<option value="">公司统一收费</option>
							                    	<#list arealist as area>
						                    			<option value="${area.id}">${area.name?if_exists}</option>
													</#list>
							                    </select>
						                	</div>
						                </div>
						                
						                <@zhuan>
							                <div class="form-group">
							                    <label class="col-sm-3 control-label"><em>*</em>专车收费：</label>
							                    <div class="col-sm-3">
								                    <select class="form-control" id="areaCarId" name="areaCarId">
								                    	<option value="">公司统一收费</option>
								                    	<#list arealist as area>
							                    			<option value="${area.id}">${area.name?if_exists}</option>
														</#list>
								                    </select>
							                	</div>
							                </div>
						                </@zhuan>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label">联系人：</label>
						                   	<div class="col-sm-3">
						                   		<input class="form-control" id="name" name="name" type="text" value="${member.name?if_exists}">
						                	</div>
						                </div>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label">客户来源：</label>
						                    <div class="col-sm-3">
						                    	<input class="form-control" id="fromSource" name="fromSource" value="${member.fromSource?if_exists}" type="text"/>
						                	</div>
						                </div>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label">常用目的地：</label>
						                    <div class="col-sm-3">
						                    	<input class="form-control" id="address" name="memberAccounts[0].address" <#if member.memberAccounts?? && (member.memberAccounts?size>0)>value="${member.memberAccounts[0].address?if_exists}"</#if> type="text"/>
						                	</div>
						                </div>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label">车牌号：</label>
						                    <div class="col-sm-3">
						                    	<input class="form-control" id="carNumber" name="memberAccounts[0].carNumber" <#if member.memberAccounts?? && (member.memberAccounts?size>0)>value="${member.memberAccounts[0].carNumber?if_exists}"</#if> type="text"/>
						                	</div>
						                </div>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label">备注：</label>
						                    <div class="col-sm-3">
						                    	<textarea class="form-control" cols="20" id="memo" name="memo" rows="2">${member.memo?if_exists}</textarea>
						                	</div>
						                </div>
						                
						                <div class="form-group">
						                    <label class="col-sm-3 control-label">是否允许签单：</label>
					                    	<div class="col-sm-3">
					                    	<p class="form-control-static">
											  <input <@shiro.lacksPermission name='allowsign'>disabled="disabled"</@shiro.lacksPermission> type="checkbox" name="isOverdraw" <#if member.isOverdraw??>${member.isOverdraw?string('checked="checked"','')}</#if>/>
											</p>
											</div>
						                </div>
						                
						                <div class="form-group">
						                	<div class="col-sm-3">
						                	</div>
						                	<div class="col-sm-3">
								                <input id="submit_button" type="submit" class="btn btn-primary" value="保存">
								                <input type="button" class="btn btn-default" onclick="window.location.href = '${ctx}/member/list';" value="返回">
							            	</div>
							            </div>
						            </form>
						        	</div>
								</div>
							</div>
						</div>
					</div>
			    </div>
			   
			</div>
		</div>
		</div>
	</div>
	

</@override>
<@override name="footer">
<script type="text/javascript">
	<#if message??>
		$.scojs_message("${message}", $.scojs_message.TYPE_ERROR);
	</#if>
	
	$(document).ready(function(){

		
		$("#submit_form").submit(function(){
			var isphone=/^\+?\d{3,13}(\-?(\d{6,8}?))?(\-?(\d{4,8}?))*$/; 
			
			var phone=$("#phone").val();

			if (!isphone.test(phone)){
				$.scojs_message("手机号格式不正确", $.scojs_message.TYPE_ERROR);
				return false;
			}
			
			$("#submit_button").attr("disabled",true);
			$.post($(this).attr("action"),$(this).serialize(),function(data){
	            if(data.success){
	                $.scojs_message('保存成功', $.scojs_message.TYPE_OK);
	                window.location='${ctx}/member/list';
	            }
	            else {
	            	$("#submit_button").attr("disabled",false);
	            	$("#CSRFToken").val(data.object);
	            	if(data.errorcode=="0"){
					    if(confirm(data.message+"，要修改该客户吗？")){
							window.location='${ctx}/member/edit/'+data.longValue;
						}
	            	}
	            	else{
	            		$.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
	            	}
	            }
		    },'json');
			
			return false;
			
		});
		
	});
</script>
</@override>
<@extends name="../layout.ftl"/>